SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

alter     trigger tfb_fixedassets_bi on dbo.tfb_fixedassets
instead of insert
as
begin
declare @bno int
  set nocount on
  declare @fixedassetid integer;
  declare @fadeltypeid integer;
  declare @newtypeid integer;
  declare @statusid integer;
  declare @fatypeid integer;
  declare @deprmethodid integer;
  declare @addvoucherid integer;
  declare @delvoucherid integer;
  declare @cardcode varchar (30);
  declare @assetcode varchar (30);
  declare @name varchar (60);
  declare @specific varchar (60);
  declare @location varchar (60);
  declare @useddate datetime;
  declare @planusemonth integer;
  declare @sumusedmonth integer;
  declare @startsumusedmonth integer;
  declare @planworkvalue decimal(18,4);
  declare @sumworkedvalue decimal(18,4);
  declare @startsumworkedvalue decimal(18,4);
  declare @workunit varchar (30);
  declare @price decimal (18,2);
  declare @quantity decimal (18,8);
  declare @unit varchar (30); 
  declare @foreignamt decimal (18,2);
  declare @foreigncurid  integer;
  declare @rawamt decimal (18,2);
  declare @sumdepramt decimal (18,2);
  declare @startsumdepramt decimal (18,2);
  declare @remainamt decimal (18,2);
  declare @remainrate decimal (18,8);
  declare @monthdepramt decimal (18,2);
  declare @monthdeprrate decimal (18,8);
  declare @deproption integer;
  declare @cleardate datetime;
  declare @clearincome decimal (18,2);
  declare @clearpay decimal (18,2);
  declare @clearmemo varchar (60);
  declare @cleared integer;
  declare @addr varchar (60);
  declare @vendorname varchar (60);
  declare @producename varchar (60);
  declare @initflag integer;
  declare @startrawamt decimal (18,2);
  declare @astsubid integer;
  declare @dprsubid integer;
  declare @filid integer;
  declare @custom1 varchar (60);
  declare @custom2 varchar (60);
  declare @custom3 varchar (60);
  declare @custom4 varchar (60);
  declare @custom5 varchar (60);
  declare @taxsubid integer;
  declare @taxamount decimal (18,2);
  declare @pictype varchar(6)
  Select
     @fixedassetid = fixedassetid,
     @fadeltypeid = fadeltypeid,
     @newtypeid = newtypeid,
     @statusid = statusid,
     @fatypeid = fatypeid,
     @deprmethodid = deprmethodid,
     @addvoucherid = addvoucherid,
     @delvoucherid = delvoucherid,
     @cardcode = cardcode,
     @assetcode = assetcode,
     @name = name,
     @specific = specific,
     @location = location,
     @useddate = useddate,
     @planusemonth = planusemonth,
     @sumusedmonth = sumusedmonth,
     @startsumusedmonth = startsumusedmonth,
     @planworkvalue = planworkvalue,
     @sumworkedvalue = sumworkedvalue,
     @startsumworkedvalue = startsumworkedvalue,
     @workunit = workunit,
     @price = price,
     @quantity = quantity,
     @unit = unit, 
     @foreignamt = foreignamt,
     @foreigncurid = foreigncurid,

     @rawamt = rawamt,
     @sumdepramt = sumdepramt,
     @startsumdepramt = startsumdepramt,
     @remainamt = remainamt,
     @remainrate = remainrate,
     @monthdepramt = monthdepramt,
     @monthdeprrate = monthdeprrate,
     @deproption = deproption,
     @cleardate = cleardate,
     @clearincome = clearincome,
     @clearpay = clearpay,
     @clearmemo = clearmemo,
     @cleared = cleared,
     @addr = addr,
     @vendorname = vendorname,
     @producename = producename,
     @initflag = initflag,
     @startrawamt = startrawamt,
     @astsubid = astsubid,
     @dprsubid = dprsubid,
     @filid = filid,
     @custom1 = custom1,
     @custom2 = custom2,
     @custom3 = custom3,
     @custom4 = custom4,
     @custom5 = custom5,
     --@pic = pic ,
     @pictype = pictype,
     @taxsubid = taxsubid,
     @taxamount = taxamount
 From Inserted;

  Set @Cleared = isnull(@Cleared,0)
  Set @SUMDEPRAMT = isnull(@SUMDEPRAMT,0)
  Set @STARTSUMDEPRAMT = @SUMDEPRAMT;    
  Set @StartSumUsedMonth = @SumUsedMonth;    
  Set @StartSumWorkedValue = @SumWorkedValue;    
  Set @MonthDeprRate = isnull(@MonthDeprRate,0)
  Set @MonthDeprAmt = isnull(@MonthDeprAmt,0)
  Set @SUMUSEDMONTH = isnull(@SUMUSEDMONTH,0)
  Set @PLANWORKVALUE = isnull(@PLANWORKVALUE,0)
  Set @taxamount = isnull(@taxamount,0)

  insert into tfb_fixedassets(
     fixedassetid,
     fadeltypeid,
     newtypeid,
     statusid,
     fatypeid,
     deprmethodid,
     addvoucherid,
     delvoucherid,
     cardcode,
     assetcode,
     name,
     specific,
     location,
     useddate,
     planusemonth,
     sumusedmonth,
     startsumusedmonth,
     planworkvalue,
     sumworkedvalue,
     startsumworkedvalue,
     workunit,
     price,
     quantity,
     unit, 
     foreignamt,
     foreigncurid,
     rawamt,
     sumdepramt,
     startsumdepramt,
     remainamt,
     remainrate,
     monthdepramt,
     monthdeprrate,
     deproption,
     cleardate,
     clearincome,
     clearpay,
     clearmemo,
     cleared,
     addr,
     vendorname,
     producename,
     initflag,
     startrawamt,
     astsubid,
     dprsubid,
     filid,
     custom1,
     custom2,
     custom3,
     custom4,
     custom5,
     pic,
     pictype,
     taxsubid,
     taxamount
  ) select 
     @fixedassetid,
     @fadeltypeid,
     @newtypeid,
     @statusid,
     @fatypeid,
     @deprmethodid,
     @addvoucherid,
     @delvoucherid,
     @cardcode,
     @assetcode,
     @name,
     @specific,
     @location,
     @useddate,
     @planusemonth,
     @sumusedmonth,
     @startsumusedmonth,
     @planworkvalue,
     @sumworkedvalue,
     @startsumworkedvalue,
     @workunit,
     @price,
     @quantity,
     @unit, 
     @foreignamt,
     @foreigncurid,
     @rawamt,
     @sumdepramt,
     @startsumdepramt,
     @remainamt,
     @remainrate,
     @monthdepramt,
     @monthdeprrate,
     @deproption,
     @cleardate,
     @clearincome,
     @clearpay,
     @clearmemo,
     @cleared,
     @addr,
     @vendorname,
     @producename,
     @initflag,
     @startrawamt,
     @astsubid,
     @dprsubid,
     @filid,
     @custom1,
     @custom2,
     @custom3,
     @custom4,
     @custom5,
     pic, 
     @pictype,
     @taxsubid,
     @taxamount
   from Inserted
end




GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

